SOPoll


C Specification

#include <dolphin/socket.h>
#define SO_POLLRDNORM       0x0001  // Normal data read
#define SO_POLLRDBAND       0x0002  // Priority data read
#define SO_POLLPRI          0x0004  // High priority data read
#define SO_POLLWRNORM       0x0008  // Normal data write
#define SO_POLLWRBAND       0x0010  // Priority data write
#define SO_POLLERR          0x0020  // Error (revents only)
#define SO_POLLHUP          0x0040  // Disconnected (revents only)
#define SO_POLLNVAL         0x0080  // Invalid fd (revents only)
#define SO_POLLIN           (SO_POLLRDNORM | SO_POLLRDBAND)
#define SO_POLLOUT          SO_POLLWRNORM

#define SO_INFTIM           -1

typedef struct SOPollFD
{
    int         fd;
    short       events;         // input event flags
    short       revents;        // output event flags
} SOPollFD;

int SOPoll( SOPollFD fds[], unsigned nfds, OSTime timeout );

Description

SOPoll() examines the socket descriptor sets to see whether some of them are ready for reading, writing, etc.

Note: SOPoll() examines the possibility of the readiness of the specified socket descriptor set. Thus the following function call to SORead(), SOWrite(), SOAccept(), etc. can still result in a sleep of the calling thread or an SO_EAGAIN error.

Arguments

fds Array of SOPollFD{}.
nfds Number of SOPollFD{} in the fds array.
timeout Timeout. Infinite timeout if SO_INFTIM.

Return Values

Positive The total number of descriptors being ready.
Zero The call timed out and no descriptors have been selected.
SO_EINVAL Invalid operation.
SO_ENETRESET Socket library is not initialized.

Note: Additional errors may be generated and returned in future library releases. All the negative return values must be treated as generic errors.

See Also